import { ApiProperty } from '@nestjs/swagger';
import { ContentType } from '../../common/enums';
import { TagResponseDto } from '../../tags/dto/tag-response.dto';
import { PaginatedResponseDto } from '../../common/dto/pagination.dto';
import { AttachmentResponseDto } from '../../attachments/dto/attachment-response.dto';

/**
 * Base response DTO for content
 */
export class ContentResponseDto {
  @ApiProperty({
    description: '内容的唯一标识',
    format: 'uuid',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  id: string;

  @ApiProperty({
    description: '内容标题',
    maxLength: 128,
    example: '如何提高工作效率',
  })
  title: string;

  @ApiProperty({
    description: '内容类型，支持纯文本(text)和Markdown',
    enum: ContentType,
    example: ContentType.MARKDOWN,
  })
  contentType: ContentType;

  @ApiProperty({
    description: '内容主体，存储原始文本或 Markdown 源码',
    example: '# 工作效率提升指南\n\n## 1. 合理规划时间\n\n时间管理是提高效率的关键...',
  })
  body: string;

  @ApiProperty({
    description: '推荐理由，可为空',
    example: '这篇文章提供了实用的工作效率提升方法',
    required: false,
    nullable: true,
  })
  recommendReason: string | null;

  @ApiProperty({
    description: '作为模板的内容 ID，非模板内容可为空',
    format: 'uuid',
    required: false,
    nullable: true,
  })
  templateId: string | null;

  @ApiProperty({
    description: '创建者用户的 ID',
    format: 'uuid',
  })
  createdBy: string;

  @ApiProperty({
    description: '创建时间',
    format: 'date-time',
  })
  createdAt: Date;

  @ApiProperty({
    description: '更新时间',
    format: 'date-time',
  })
  updatedAt: Date;

  @ApiProperty({
    description: '是否审核通过',
    default: false,
  })
  isApproved: boolean;

  @ApiProperty({
    description: '是否被删除，软删除标记',
    default: false,
  })
  isDeleted: boolean;
}

/**
 * Content response DTO with tags and attachments
 */
export class ContentDetailResponseDto extends ContentResponseDto {
  @ApiProperty({
    description: '关联的标签列表',
    type: [TagResponseDto],
  })
  tags: TagResponseDto[];

  @ApiProperty({
    description: '关联的附件列表',
    type: [AttachmentResponseDto],
  })
  attachments: AttachmentResponseDto[];
}

/**
 * Response DTO for content list with pagination
 */
export class ContentListResponseDto extends PaginatedResponseDto<ContentDetailResponseDto> {}

/**
 * Response DTO for deleting content
 */
export class DeleteContentResponseDto {
  @ApiProperty({
    description: 'Status message',
    example: 'Content deleted successfully',
  })
  message: string;
}
